/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 *
 * @author carlos
 */
@Entity
public class Veiculo implements Serializable {
  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  
  @Pattern(regexp = "d^[a-zA-Z]{3}\\-\\d{4}$")
  @NotNull(message = "Campo obrigatório")
  @Column(unique = true, nullable = false)
  private String placa;
  
  @ManyToOne
  private Marca marca;
  
  @ManyToOne
  private Modelo modelo;
  
  @ManyToOne
  private Cliente proprietario;
  
  @Digits(integer = 11, fraction = 4)
  @Column(precision = 15, scale = 4)
  private BigDecimal valor;

  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getPlaca() {
    return placa;
  }

  public void setPlaca(String placa) {
    this.placa = placa;
  }

  public Marca getMarca() {
    return marca;
  }

  public void setMarca(Marca marca) {
    this.marca = marca;
  }

  public Modelo getModelo() {
    return modelo;
  }

  public void setModelo(Modelo modelo) {
    this.modelo = modelo;
  }

  public Cliente getProprietario() {
    return proprietario;
  }

  public void setProprietario(Cliente proprietario) {
    this.proprietario = proprietario;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (id != null ? id.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Veiculo)) {
      return false;
    }
    Veiculo other = (Veiculo) object;
    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "model.entity.Veiculo[ id=" + id + " ]";
  }
  
}
